<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('产值报表')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
</head>
<style>
    select {
        padding-top: 3px !important;
    }

    .select-list {
        margin-top: 5px !important;
    }

    .select-list li p {
        width: auto !important;
        margin-top: 7px !important;
    }
</style>
<body class="gray-bg">

<div class="ui-layout-center">
    <div class="container-div">

        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="project-form">
                    <div class="col-sm-12">


                        <div class="select-list">
                            <ul>
                                <li>
                                    <p>工程公司：</p>
                                    <select name="compId" id="compId" class="form-control">
                                        <option value="">请选择</option>
                                        <option th:each="pro:${userComp}" th:value="${pro.compId}"
                                                th:text="${pro.compName}"></option>
                                    </select>

                                </li>
                                <li>
                                    <p>项目名称：</p>
                                    <select class="form-control noselect2" id="proName" name="proName">
                                        <option value="">请选择</option>
                                    </select>
                                </li>
                                <li>
                                    <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                            class="fa fa-search"></i>&nbsp;搜索</a>
                                    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                            class="fa fa-refresh"></i>&nbsp;重置</a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </form>
            </div>
            <div class="col-sm-12 select-table table-striped">

                <div class="btn-group-sm" id="toolbar" role="group">
                    <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="outPutValue:add">
                        <i class="fa fa-plus"></i> 新增
                    </a>
                    <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
                       shiro:hasPermission="outPutValue:edit">
                        <i class="fa fa-edit"></i> 修改
                    </a>
                    <a class="btn btn-danger" onclick="$.operate.removeAll()" shiro:hasPermission="outPutValue:remove">
                        <i class="fa fa-remove"></i> 删除
                    </a>
                    <a class="btn btn-warning" onclick="$.table.exportData('项目信息')"
                       shiro:hasPermission="project:user:export">
                        <i class="fa fa-download"></i> 导出Excel
                    </a>
                    <a class="btn btn-primary" onclick="$.modal.openTab('填写每月全部产值','outPutValue/outPutValueYearMonth');">
                        <i class="fa fa-edit"></i> 填写每月全部产值
                    </a>

                </div>

                <table id="bootstrap-table"></table>

            </div>
        </div>
    </div>
</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<script th:inline="javascript">
    var prefix = ctx + "outPutValue";

    $(function () {
        $("#compId").change(function () {
            compId = $("#compId option:selected").val();
            $.ajax({
                url: prefix + '/findProByCompId',
                data: {
                    "compId": compId
                },
                success: function (data) {
                    $("#proName").find("option").remove();
                    $("#proName").append('<option value="">请选择</option>');
                    // if ($("#compId option:selected").val() == "") {
                    //     $("#proName").append('<option value="">请选择</option>')
                    // }
                    for (var i in data.data) {
                        html = data.data[i].pro_name;
                        value = data.data[i].comp_id;
                        $("#proName").append('<option value="' + html + '">' + html + '</option>')
                    }
                }
            })
        });


        var options = {
            code: "id",
            uniqueId: "id",
            url: prefix + '/list',
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",

            modalName: "项目信息",
            columns: [{
                checkbox: true
            },
                {
                    field: 'compName',
                    title: '工程公司',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a href="javascript:void(0)" onclick="pierce(\'' + 1 + '\',\'' + row.id + '\')">' + row.compName + '</a> ');
                        return actions.join('');
                    }

                },
                {
                    field: 'proName',
                    title: '项目名称',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a href="javascript:void(0)" onclick="pierce(\'' + 2 + '\',\'' + row.id + '\')">' + row.proName + '</a> ');
                        return actions.join('');
                    }
                },
                {
                    field: 'gcPerson',
                    title: '工程负责人',

                },
                {
                    field: 'swPerson',
                    title: '商务负责人',

                },
                {
                    field: 'contractAmount',
                    title: '合同额',

                },
                {
                    field: 'startDate',
                    title: '开工时间',

                },
                {
                    field: 'expectedCompletionDate',
                    title: '预计竣工时间',

                },
                {
                    field: 'previousOutputValue',
                    title: '往期产值(万元)',

                },
                {
                    title: '利润率%',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push(row.profitMargin + "%" );
                        return actions.join('');
                    }
                }]
        };

        $.table.init(options);

    });

    function pierce(type, id) {
        $.modal.openTab('填写每月全部产值', 'outPutValue/outPutValueYearMonth?type=' + type + "&id=" + id);
    }

</script>
</body>

</html>